<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var a = 10;
        var b = 20;

        function fun() {
            c = 30;
            var b = 40;
            b++;
            c++
        }
        fun();
        console.log(b);
        console.log(c);

        var numbers = [1, 2, 3, 4, 5, 6, 7]

        var sum = numbers.reduce((total, num, currentIndex, arr) => {
            if ((numbers.length - currentIndex) < 4) return total + 0
            return total + num
        })
        console.log('sum', sum);
    </script>
</body>

</html>